<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	
	<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<style type="text/css">
		
		
	</style>
	<title>CRM-注册</title>
	<style type="text/css">
		.red,.regExp{
			display:none;
			color:red;
		}
		.green,.pwdRight{
			display:none;
			color:green;
		}
	
	</style>
</head>
<body>
		<%@ include file="include/base.jsp" %>
		<%@ include file="include/base-before.jsp" %>
	
		
		<div class="container">
			<h2>欢迎注册...</h2>
			<hr/>
			<div class="span8">
			  <form class="form-horizontal" action="registerEmployee.jspx" id="myform"  method="post">
				<fieldset>
				  <div class="control-group">
					<label for="input01" class="control-label">公司名称</label>
					<div class="controls">
					  <input type="text" id="company" name="employee.companyname" class="input-xlarge">
					  <p class="help-block">团队,公司,或者学校</p>
					</div>
				  </div>
				  <div class="control-group">
					<label for="optionsCheckbox" class="control-label">*姓名</label>
					<div class="controls">
						<input type="text" id="username" name="employee.name" class="input-xlarge">
				  	</div>
				  </div>
				  <div class="control-group">
					<label for="optionsCheckbox" class="control-label">*&nbspE-mail</label>
					<div class="controls">
						<input type="text" id="email" style="display:inline" name="employee.email" class="input-xlarge">
						<img id="loading" style="display:none" src="image/ajax.gif"></img>
						<span id="red" class="red">此Email已被注册!</span>
						<span class="green">√</span>
						<span id="regExp" class="regExp">邮箱格式不正确!</span>
						<br/>
						<p class="help-block">用来登录的账号</p>
					</div>
				  </div>
				  <div class="control-group">
					<label for="optionsCheckbox" class="control-label">*&nbsp密码</label>
					<div class="controls">
						<input type="password" id="pwd" style="display:inline" name="employee.password" class="input-xlarge">
						<span class="pwdRight">√</span>
					</div>
				  </div>
				  <div class="control-group">
					<label for="optionsCheckbox" class="control-label">再次输入密码</label>
					<div class="controls">
						<input type="password" id="secondPwd" style="display:inline" class="input-xlarge">
						<span class="red" id="secongPwdRed">两次密码不一致,请核实!</span>
						<span class="pwdRight">√</span>
					</div>
				  </div>
				  <div class="form-actions">
					<button id="register-btn" type="submit"  class="register-btn btn btn-primary btn-small" >&nbsp&nbsp注册&nbsp&nbsp</button>
					<button class="register-btn btn">取消</button>
				  </div>
				</fieldset>
			  </form>
			  
			</div>
			<div class="span3 well">
				<h2>选择我们,选择成功!</h2><br/>
				<h4>机会从中来</h4><br/>
				<h4>机遇从中来</h4><br/>
				<h4>成功自然来</h4><br/>
			
			</div>
		
		</div>
		
		
		<script type="text/javascript">
			
			$(document).ready(function(){
			
				$('#register-btn').click(function(){
					if($('#username').val() == "" || $('#username').val() == null){
						$('#username').focus();
						return;
					}
					if($('#email').val() == "" || $('#email').val() == null){
						$('#email').focus();
						return;
					}
					if( $('#pwd').val() == "" || $('#pwd').val() == null){
						$('#pwd').focus();
						return;	
					}
					if( $('#secongPwdRed').val() == "" || $('#secongPwdRed').val() == null){
						$('#secongPwdRed').focus();
						return;	
					} 
					
				});
				
				
				$('#secondPwd').blur(function(){
					if($('#pwd').val() != $('#secondPwd').val()){
						$('#secongPwdRed').show();				
					} else {
						$('#secongPwdRed').hide();
						$('.pwdRight').show();
					};
				});
				
				
			
				$('#email').change(function(){
					var email = $('#email').val();
					if(testEmail(email) ){
						$.get("email.jspx",{"mail":email},function(xml){
							if(xml == true){
								$('.green').show();
								$('.red').hide();
								$('#regExp').hide();
							} else {
								$('#red').show();
								$('.green').hide();
								$('#regExp').hide();
							}
						});
						
					} else {
						$('#regExp').show();
						$('.green').hide();
						$('.red').hide();
					}
					
					function testEmail(email){
						var patten = new RegExp(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]+$/);
						return patten.test(email);
					}
				});
				
				
			});
		
		</script>
		
		

</body>
</html>